#include "uti_tradeseries.h"





TradeSeries::TradeSeries(TradeSerInfo* pserinfo)
{
	memcpy(&m_tradeserinfo, pserinfo, sizeof(m_tradeserinfo));

	m_pmemman = new MemMan<TradeData>(m_tradeserinfo.sersize, m_tradeserinfo.p);

	m_pmemman->InitUnitPointer(&m_ptradecur, &m_tradeindex);

}

TradeSeries::~TradeSeries()
{
	if (NULL != m_pmemman)
	{
		delete m_pmemman;
	}
}


void TradeSeries::AddTrade(CThostFtdcTradeField* ptrade)
{
	NewTrade(ptrade);
}


void TradeSeries::NewTrade(CThostFtdcTradeField* ptrade)
{
	///////This is not work logic but memory management logic ///////////
	if (m_ptradecur->tradecnt != 0) 
	{

		m_pmemman->NextUnitPointer(&m_ptradecur,&m_tradeindex);//get cur bar pointer and index

	}

	m_ptradecur->tradecnt++;

	memcpy(&m_ptradecur->data, ptrade, sizeof(CThostFtdcTradeField));


}

void TradeSeries::OldTrade(CThostFtdcTradeField* ptrade)
{

}


